export default class orc_prefab extends Laya.Script {  
    public static _alert_loading:any;
    public static _alert_position:number = 0;

    constructor() { super(); }

    public static show_alert_tips(text:string){               
        if(orc.res_manager.prefabs_res["prefabs/alert_tip.json"])
        {    
            let alert_tip_prefab:Laya.Prefab = new Laya.Prefab();
            alert_tip_prefab.json = orc.res_manager.prefabs_res["prefabs/alert_tip.json"].json;
            let node:Laya.Node = alert_tip_prefab.create();
            
            let node_sprite:Laya.Sprite = node as Laya.Sprite;
            node_sprite.zOrder = 999;
            node_sprite.alpha = 1;
            Laya.stage.addChild(node);
            let label:Laya.Text = node.getChildByName('tips_label') as Laya.Text;
            label.text = text;
            this._alert_position = node_sprite.y;         

            Laya.timer.once(1000,this,function(){
                this._alert_position = node_sprite.y;      
                var asd = this._alert_position - 50;
                Laya.Tween.to(node,{ y : asd,alpha:0 }, 500,Laya.Ease.linearIn,Laya.Handler.create(this,()=>{
                    node.removeSelf();
                }));
            })          
        }
    }

    public static show_loading_tip(){ 
        if(orc.res_manager.prefabs_res["prefabs/loading_tip.json"])
        {
            let loading_tip_prefab:Laya.Prefab = new Laya.Prefab();
            loading_tip_prefab.json = orc.res_manager.prefabs_res["prefabs/loading_tip.json"].json;
            let node:Laya.Node = loading_tip_prefab.create();
            
            let node_sprite:Laya.Sprite = node as Laya.Sprite;
            node_sprite.zOrder = 999;
            node_sprite.alpha = 1;
            node_sprite.height = Laya.stage.height;        
            Laya.stage.addChild(node);
            this._alert_loading = node;
            Laya.timer.once(5000,this,()=>{
                this.shut_loading_tip();
            })
        }       
    }

    public static win_open(win_name:string){
        let win_node = Laya.stage.getChildByName(win_name);
        orc.log('win_node',win_node)
        if(win_node)
        {
            return;
        }
        let win_temp = "prefabs/win/" + win_name + ".json";
        orc.log('win_node',win_temp)
        if(orc.res_manager.prefabs_res[win_temp]){
            let loading_tip_prefab:Laya.Prefab = new Laya.Prefab();
            loading_tip_prefab.json = orc.res_manager.prefabs_res[win_temp].json;
            let node:Laya.Node = loading_tip_prefab.create();
            
            let node_sprite:Laya.Sprite = node as Laya.Sprite;
            node_sprite.zOrder = 999;
            node_sprite.alpha = 1;
            node_sprite.height = Laya.stage.height;            
            Laya.stage.addChild(node);
        }
    }

    public static win_close(win_name:string){
        let win_node = Laya.stage.getChildByName(win_name);
        if(!win_node)
        {
            return;
        }
        orc.log('win_node find:',win_node);
    }

    public static shut_loading_tip(){
        if(this._alert_loading)
        {
            this._alert_loading.removeSelf();
        }        
    }


    onEnable(): void {
        
    }

    onDisable(): void {
    }
}